{% macro create(url) %}
    <div class="clearfix form-actions">
        <div class="col-md-offset-3 col-md-9">
            <button class="btn btn-info" type="submit">
                <i class="ace-icon fa fa-check bigger-110"></i>
                {{ 'Submit'|trans }}
            </button>
            &nbsp; &nbsp; &nbsp;
            <button class="btn" type="button" onclick="cancelRedirect('{{ url }}')">
                <i class="ace-icon fa fa-undo bigger-110"></i>
                {{ 'Returns a list of'|trans }}
            </button>
        </div>
    </div>
{% endmacro %}

{% macro submit() %}
    <div class="col-md-offset-3 col-md-9">
        <button class="btn btn-info" type="submit">
            <i class="ace-icon fa fa-check bigger-110"></i> {{ 'Submit'|trans }}
        </button>
    </div>
{% endmacro %}

{% macro save() %}
    <div class="col-md-offset-3 col-md-9">
        <button class="btn btn-info" type="submit">
            <i class="ace-icon fa fa-check bigger-110"></i> {{ 'Save'|trans }}
        </button>
    </div>
{% endmacro %}

{% macro cancel() %}
    <div class="col-md-offset-3 col-md-9">
        <button class="btn btn-info" type="button">
            <i class="ace-icon fa fa-check bigger-110"></i> {{ 'Cancel'|trans }}
        </button>
    </div>
{% endmacro %}

{% macro button(name, id, icon, type) %}
    {#<div class="col-md-offset-3 col-md-9">#}
        <button id="{{ id }}" class="btn {{ type|default('btn-primary') }}" type="button">
            <i class="ace-icon fa {{ icon|default('fa-check') }} bigger-110"></i> {{ name|trans }}
        </button>
    {#</div>#}
{% endmacro %}

{% macro widgetButton() %}
    <div class="widget-toolbar no-border">
        <a href="#" data-action="collapse">
            <i class="ace-icon fa fa-chevron-up"></i>
        </a>
    </div>
{% endmacro %}

{% macro datetime(id, value) %}
    <div class="row" style="margin-right: 0">
        <div class="col-sm-6">
            <input type="text" class="col-sm-12" id="{{ id }}" placeholder="" value="{{ value }}">
        </div>
    </div>
{% endmacro %}

{% macro searchtime(svalue,evalue) %}
    {% import _self as date %}
    <tr>
        <td class="col-xs-2 align-right align-middle" style="border-right-width: 0px;">
            <label for="start_time">{{ 'Start time'|trans }}:</label>
        </td>
        <td class="col-xs-4" style="border-left-width: 0px;">
            {{ date.datetime('start_time', svalue) }}
        </td>
        <td class="col-xs-2 align-right align-middle" style="border-right-width: 0px;">
            <label for="end_time">{{ 'End time'|trans }}:</label>
        </td>
        <td class="col-xs-4" style="border-left-width: 0px;">
            {{ date.datetime('end_time', evalue) }}
        </td>
    </tr>
{% endmacro %}

{% macro searchDay(svalue,evalue) %}
    {% import _self as date %}
    <tr>
        <td class="col-xs-2 align-right align-middle" style="border-right-width: 0px;">
            <label for="start_time">开始日期:</label>
        </td>
        <td class="col-xs-4" style="border-left-width: 0px;">
            {{ date.datetime('start_time', svalue) }}
        </td>
        <td class="col-xs-2 align-right align-middle" style="border-right-width: 0px;">
            <label for="end_time">结束日期:</label>
        </td>
        <td class="col-xs-4" style="border-left-width: 0px;">
            {{ date.datetime('end_time', evalue) }}
        </td>
    </tr>
{% endmacro %}

{% macro timebutton() %}
    <tr>
        <td colspan="4" class="text-center line-height-0">
            <button type="button" class="btn btn-white btn-primary btn-sm" onclick="fnSetTime(1)">{{ 'Yesterday'|trans }}</button>
            <button type="button" class="btn btn-white btn-primary btn-sm" onclick="fnSetTime(2)">{{ 'Today'|trans }}</button>
            <button type="button" class="btn btn-white btn-primary btn-sm" onclick="fnSetTime(3)">{{ 'Last Week'|trans }}</button>
            <button type="button" class="btn btn-white btn-primary btn-sm" onclick="fnSetTime(4)">{{ 'This Week'|trans }}</button>
            <button type="button" class="btn btn-white btn-primary btn-sm" onclick="fnSetTime(5)">{{ 'Last Month'|trans }}</button>
            <button type="button" class="btn btn-white btn-primary btn-sm" onclick="fnSetTime(6)">{{ 'This Month'|trans }}</button>
            <button type="button" class="btn btn-white btn-primary btn-sm forBaidu" onclick="fnSetTime(7)">{{ 'This Year'|trans }}</button>
            <button type="button" class="btn btn-white btn-primary btn-sm forBaidu" onclick="fnSetTime(8)">{{ 'Last Year'|trans }}</button>
        </td>
    </tr>
{% endmacro %}

{% macro searchForm(actions) %}
    {% for key,action in actions %}
        {% if loop.index0 % 2 == 0 %}
            <tr>
        {% endif %}
            <td class="col-xs-2 align-right align-middle" style="border-right-width: 0px;">
                <label for="{{ key }}">{{ action.text|trans }}:</label>
            </td>
            <td class="col-xs-4" style="border-left-width: 0px;">
                {% if action.type == 1 %}
                    <input type="text" id="{{ key }}" name='{{ key }}' placeholder="{% if action.help is defined %}{{ action.help|trans }}{% endif %}" class="col-xs-12 col-sm-6 input-sm" />
                {% elseif action.type == 2 %}
                    {% if key == 'que_id' or key == 'que_id_trans' or key == 'group_id' or key == 'evaluates' %}
                        <select id="{{ key }}" name="{{ key }}" style="width:18%;" class="chosen-select col-xs-12 col-sm-6">
                            <option value="{% if action.all is defined %}{{ action.all }}{% else %}-1{% endif %}">{{ 'All'|trans }}</option>
                            {% for opKey,option in action.options %}
                                <option value="{{ opKey }}" {% if action.selected is defined and opKey == action.selected %}selected{% endif %}>{{ option }}</option>
                            {% endfor %}
                        </select>
                    {% elseif key == 'ag_num' %}
                        <select id="forAgent-{{ key }}" name="{{ key }}" style="width:18%;" class="chosen-select col-xs-12 col-sm-6">
                            <option value="{% if action.all is defined %}{{ action.all }}{% else %}-1{% endif %}">{{ 'All'|trans }}</option>
                        </select>
                    {% else %}
                        <select id="{{ key }}" name="{{ key }}" style="width:16.5%;" class="chosen-select col-xs-12 col-sm-6 normal-select">
                            <option value="{% if action.all is defined %}{{ action.all }}{% else %}-1{% endif %}">{{ 'All'|trans }}</option>
                        {% if action.options is defined %}
                            {% for opKey,option in action.options %}
                                <option value="{{ opKey }}" {% if action.selected is defined and opKey == action.selected %}selected{% endif %}>{{ option }}</option>
                            {% endfor %}
                        {% endif %}
                        </select>
                    {% endif %}
                {% elseif action.type == 3 %}
                    {% set index=1 %}
                    {% for key,evaluateConfig in action.options %}
                    <select name="evaluate{{ key }}" class="evaluates {% if index != 1 %} evaluates-custom  {% endif %}" {% if action.options|length == 1 %} style="width: 50%;" {% else %}style="width:24.5%" {% endif %}>
                        <option value="-5">全部</option>
                        {% if index == 1 %}
                            <option value="-1" class="unEvaluated">客户挂机</option>
                            <option value="-3" class="unEvaluated">未评价挂机</option>
                            <option value="-4" class="unEvaluated">坐席挂机</option>
                        {% endif %}
                        {% for k,v in evaluateConfig.keys %}
                            <option value="{{ v.id }}">{{ v.name }}</option>
                            {% if v.child is defined and v.child is not empty %}
                                {% for childId,childConfig in v.child.keys %}
                                    <option value="{{ childConfig.id }}" >
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|-{{ childConfig.name }}
                                    </option>
                                {% endfor %}
                            {% endif %}
                        {% endfor %}
                    </select>
                        {% set index = index+1 %}
                    {% endfor %}
                {% endif %}
            </td>
    {% if loop.index % 2 == 0 %}
        </tr>
    {% endif %}
    {% endfor %}
{% endmacro %}

{% macro searchFormBtn() %}
    <tr>
        <td colspan="4" class="text-center">
            <button id="loading-btn" type="submit" class="btn btn-info btn-sm">
                <i class="ace-icon fa fa-search"></i> {{ 'Inquiry'|trans }}
            </button>
            <button id="loading-btn" type="button" class="btn btn-pink btn-sm" onclick="resetBtn()">
                <i class="ace-icon fa fa-undo"></i> {{ 'Reset'|trans }}
            </button>
        </td>
    </tr>
{% endmacro  %}

{% macro playSound() %}
    <tr>
        <td colspan="4" class="text-left">
            <audio id="sound_player" class="align-middle" style="margin-top: 8px;color: white;width: 100%;" autoplay="autoplay"
                   controls="controls" src="">{{ 'Your browser does not support the player'|trans }}
            </audio>
        </td>
</tr>
{% endmacro %}
